package jbpm.example.workflow;

import com.google.inject.Inject;
import jbpm.example.preciouscode.Registration;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;


public class RegistrationAction implements ActionHandler {

    private static final long serialVersionUID = -5139735109844353866L;

    private Registration registration;

    private String geekCharacteristic;

    static int executionCounter;

    @Inject
    public RegistrationAction(Registration inj) {
        this.registration = inj;
    }

    public void execute(ExecutionContext executionContext) throws Exception {
        registration.registerGeek(executionCounter++, geekCharacteristic);
    }

    public void setGeekCharacteristic(String geekCharacteristic) {
        this.geekCharacteristic = geekCharacteristic;
    }

    public String getGeekCharacteristic() {
        return geekCharacteristic;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("jbpm.example.jbpmguice.workflow.RegistrationAction");
        sb.append("{counter=").append(executionCounter);
        sb.append('}');
        return sb.toString();
    }
}
